# coding=utf-8

# from urllib.request import urlopen
# from bs4 import BeautifulSoup
from selenium import webdriver

# csv_file = open("result.csv", "w", newline='')
# writer = csv.writer(csv_file)
# writer.writerow(['name', 'price', 'vip_price', 'count'])

# url = 'https://coll.jd.com/list.html?sub=39866&delivery=0&page=0&JL=4_10_0'

# 浏览器参数，有无优化？！
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument(r"user-data-dir=C:\Users\Administrator\AppData\Local\Google\Chrome\User Data")
# chrome_options.add_argument('--no-sandbox')
# chrome_options.add_argument('--headless')
# chrome_options.add_argument('--disable-gpu')
# prefs = {'profile.default_content_settings.popups': 0, 'download.default_directory': 'I:\\'}
# chrome_options.add_experimental_option('prefs', prefs)
driver = webdriver.Chrome(executable_path=r"D:\Python\Python37\Scripts\chromedriver.exe", chrome_options=chrome_options)

# driver.get('https://www.vmall.com/')
# driver.find_element_by_id("top-index-loginUrl").click()

driver.get("https://www.douban.com/")
# driver.find_element_by_id("login_userName").send_keys("...")
# driver.find_element_by_id("login_password").send_keys("...")
# driver.find_element_by_id("btnLogin").click()
# time.sleep(10)
# cookies = driver.get_cookies()
# print(cookies)
# driver.quit()

# time.sleep(3)
# c1={...}
# driver.add_cookie(c1)
# time.sleep(3)
# 
# #刷新之后观察是否已经登录成功
# driver.refresh()
# time.sleep(5)
